<?php
/**
 * Class descript.
 * User: chen guang
 * Date: 2017/10/26 15:29
 */
namespace app\api\controller;
use \app\api\logic\Coupon as CouponLogic;
use think\Controller;
use think\Request;
class Coupon extends Base
{
    //检查权限作用域
    protected $beforeActionList  = [
        'checkPrimaryScope' => [
//          'except' => 'except'
            'only' => 'cardlist,couponlist,backMoney,detail,deletecoupon,check,getpackage,getpage'
        ],
    ];

    public function __construct(Request $request){
        parent::__construct($request);
        $this->request = $request;
        $this->CouponLogic = new CouponLogic();//逻辑业务
    }
    //获取颜色
    public function color(){
        return $this->ajaxReturn(
            $this->CouponLogic->color()
        );
    }
    //创建卡券
    public function createCard(){
        return $this->ajaxReturn(
            $this->CouponLogic->createCard()
        );
    }
    //领券中心列表
    public function cardlist(){
        return $this->ajaxReturn(
            $this->CouponLogic->cardlist()
        );
    }

    public function jsCard()
    {
        $cardData = (array)json_decode(
            $this->CouponLogic->jsCard()
        );
        $this->assign('cardData',$cardData);
        return $this->fetch();
    }
    //我的优惠券
    public function couponlist(){
        return $this->ajaxReturn(
            $this->CouponLogic->couponlist()
        );
    }
    //判断优惠券可用星期
    public function check(){
        return $this->ajaxReturn(
            $this->CouponLogic->check()
        );
    }
    //优惠详情
    public function detail(){
        return $this->ajaxReturn(
            $this->CouponLogic->detail()
        );
    }
    //删除优惠券
    public function delcoupon(){
        return $this->ajaxReturn(
            $this->CouponLogic->delcoupon()
        );
    }
    //weixin优惠详情
    public function wxdetail(){
        return $this->ajaxReturn(
            $this->CouponLogic->wxdetail()
        );
    }
    //核销优惠券
    public function deletecoupon(){
        return $this->ajaxReturn(
            $this->CouponLogic->deletecoupon()
        );
    }
    public function white(){
        return $this->ajaxReturn(
            $this->CouponLogic->white()
        );
    }
    //创建卡券
    public function createMemberCard(){
        return $this->ajaxReturn(
            $this->CouponLogic->createMemberCard()
        );
    }
    public function getpackage(){
        return $this->ajaxReturn(
            $this->CouponLogic->getHuiYuanSignPackage()
        );
    }

    public function getsignpackage(){
        return $this->ajaxReturn(
            $this->CouponLogic->getSignPackage()
        );
    }

    public function getpage(){
        return $this->ajaxReturn(
            $this->CouponLogic->getpage()
        );
    }
}